home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS Toolkit
/
BBS Toolkit.iso
/
pc_board
/
sfa.zip
/
SFA.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1991-10-13
|
10KB
|
280 lines
program SetFileArea;
uses Dos;
{
Title : SFA.PAS (Changes privileges of ALL files in one area in FILESBBS.DAT)
Version : 1.0 -- *ONLY* For Opus 1.7x or above
LastEdit: October 13, 1991 -- For exclusive use of his Boss Alberto Enna
Author : Gianfranco "Frankie" Lanzilli - CoSysOp on ]\/[imac Opus BBs (+39-6-2751446) Rome,Italy - 2:335/12@fidonet.org
System : Borland Turbo Pascal v5.5 (MS-DOS)
}
const ItemLen = 64;
var FNam : string;
FDat : file of byte;
FPos : longint;
ANum : word;
FPF, FPT : byte;
procedure Configure;
var ThisExeFile : file of char;
CheckString : string[4];
FAttr : word;
FTime : longint;
C, K : char;
I : byte;
function KeyPressed : boolean;
var Regs : Registers;
begin {KeyPressed}
Regs.AH := $0B;
MsDos(Regs);
case Regs.AL of
$00 : KeyPressed := false;
$FF : KeyPressed := true
end {case}
end; {KeyPressed}
function ReadKey : char;
var Regs : Registers;
begin {ReadKey}
Regs.AH := $08;
Msdos(Regs);
ReadKey := Chr(Regs.AL)
end; {ReadKey}
begin {Configure}
Assign(ThisExeFile,ParamStr(0));
GetFAttr(ThisExeFile,FAttr);
SetFAttr(ThisExeFile,Archive);
Reset(ThisExeFile);
GetFTime(ThisExeFile,FTime);
Seek(ThisExeFile,(FileSize(ThisExeFile)-4));
CheckString := '';
for I := 1 to 4 do
begin
Read(ThisExeFile,C);
CheckString := (CheckString + C)
end;
if (CheckString <> '*SFA') then
begin
Writeln(' Frankie''s SetFileAreas v1.0');
Writeln(' ~~~~~~~~~~~~~~~~~~~~~~~~~~~');
Writeln(' This copy of the program has NOT been configured yet.');
Writeln(' Configuration is quick and easy; please input at the prompt the pathname');
Writeln(' of your Opus 1.7x FilesBbs.Dat; for example: C:\OPUS\FILESBBS.DAT.');
Writeln;
Writeln(' Now, type in, or press <Control-Break> to stop:');
Write(' FilesBbsDatFile>');
Readln(FNam);
Writeln;
Writeln(' Thank you.');
Writeln(' If you made a mistake, you can press <Control-Break> to stop now, before the');
Writeln(' configuration is written to the EXE file, or press <Return> if all is OK.');
Writeln(' Remember, there''s no way to change this configuration, so if you want to do');
Writeln(' so, you should restart with a brand new copy of the program.');
Writeln;
Writeln(' IMPORTANT: the EXE file of the program cannot be compressed when configured!');
Writeln(' However, it has already been compressed with PkLite by me.');
Writeln;
Writeln(' Gianfranco "Frankie" Lanzilli');
Writeln(' CoSysOp Opus ]\/[imac BBs - FidoNet 2:335/12 - +39-6-2751446 - Roma, Italy');
Write(' Press <Return> to continue, or <Control-Break> to abort...');
repeat
repeat until KeyPressed;
C := ReadKey;
if (C = #0) then
K := ReadKey
until (C = #13);
Writeln;
Writeln;
Seek(ThisExeFile,FileSize(ThisExeFile));
C := '*';
Write(ThisExeFile,C);
while ((FNam[1] = #9) or (FNam[1] = #32)) do
Delete(FNam,1,1);
while ((FNam[Length(FNam)] = #9) or (FNam[Length(FNam)] = #32)) do
Delete(FNam,Length(FNam),1);
for I := 1 to Length(FNam) do
begin
Seek(ThisExeFile,FileSize(ThisExeFile));
C := UpCase(FNam[I]);
Write(ThisExeFile,C)
end;
CheckString := '*SFA';
for I := 1 to Length(CheckString) do
begin
Seek(ThisExeFile,FileSize(ThisExeFile));
Write(ThisExeFile,CheckString[I])
end;
SetFTime(ThisExeFile,FTime);
Close(ThisExeFile);
SetFAttr(ThisExeFile,FAttr)
end
else
Close(ThisExeFile)
end; {Configure}
procedure GetName (var N : string);
var ThisExeFile : file of char;
C : char;
begin {GetName}
Assign(ThisExeFile,ParamStr(0));
Reset(ThisExeFile);
Seek(ThisExeFile,(FileSize(ThisExeFile)-5));
Read(ThisExeFile,C);
N := '';
while (C <> '*') do
begin
N := C + N;
Seek(ThisExeFile,(FilePos(ThisExeFile)-2));
Read(ThisExeFile,C)
end;
Close(ThisExeFile)
end; {GetName}
procedure CheckCommandLine (var AN : word; var PF, PT : byte);
function PrivByte (Privilege : string) : byte;
var K : byte;
begin {PrivByte}
for K := 1 to Length(Privilege) do
Privilege[K] := UpCase(Privilege[K]);
if (Privilege = 'TWIT') then PrivByte := $10 else
if (Privilege = 'DISGRACE') then PrivByte := $30 else
if (Privilege = 'LIMITED') then PrivByte := $40 else
if (Privilege = 'NORMAL') then PrivByte := $50 else
if (Privilege = 'WORTHY') then PrivByte := $60 else
if (Privilege = 'PRIVIL') then PrivByte := $70 else
if (Privilege = 'FAVORED') then PrivByte := $80 else
if (Privilege = 'EXTRA') then PrivByte := $90 else
if (Privilege = 'CLERK') then PrivByte := $A0 else
if (Privilege = 'ASSTSYSOP') then PrivByte := $B0 else
if (Privilege = 'SYSOP') then PrivByte := $D0 else
if (Privilege = 'HIDDEN') then PrivByte := $E0 else
begin
Writeln;
Writeln('"',Privilege,'" is NOT a valid Privilege Class.');
Writeln('Choose one of the following:');
Writeln(' 01> Twit 04> Normal 07> Favored 10> AsstSysop');
Writeln(' 02> Disgrace 05> Worthy 08> Extra 11> Sysop');
Writeln(' 03> Limited 06> Privil 09> Clerk 12> Hidden');
Halt
end
end; {PrivByte}
function Get_Word (S : string) : word;
var Aux : longint;
Err : integer;
begin {Get_Word}
Val(S,Aux,Err);
if ((Err > 0) or ((Err = 0) and ((Aux < 0) or (Aux > 65535)))) then
begin
Writeln;
Writeln('"',S,'" is NOT a valid Area Number.');
Writeln('This should be a INTEGER value in the range: 0 .. 65535.');
Halt
end
else
Get_Word := Aux
end; {Get_Word}
begin {CheckCommandLine}
if (ParamCount <> 3) then
begin
Writeln;
Writeln('Usage: SFA <AreaNumber> <PrivilegeFrom> <PrivilegeTo>');
Writeln;
Writeln(' If the download privilege of a file in area <AreaNumber> is <PrivilegeFrom>,');
Writeln(' then it is set to <PrivilegeTo>.');
Writeln;
Writeln(' <AreaNumber> must be an INTEGER value in the range: 0 .. 65535.');
Writeln;
Writeln(' Possible values for <PrivilegeFrom> and <PrivilegeTo> are:');
Writeln(' Twit Limited Worthy Favored Clerk Sysop');
Writeln(' Disgrace Normal Privil Extra AsstSysop Hidden');
Writeln;
Writeln(' **** Yet another Frankie''s production, 1991 ****');
Halt
end
else
begin
AN := Get_Word(ParamStr(1));
PF := PrivByte(ParamStr(2));
PT := PrivByte(ParamStr(3))
end
end; {CheckCommandLine}
function PrivStr (PC : byte) : string;
begin {PrivStr}
case PC of
$10 : PrivStr := 'Twit';
$30 : PrivStr := 'Disgrace';
$40 : PrivStr := 'Limited';
$50 : PrivStr := 'Normal';
$60 : PrivStr := 'Worthy';
$70 : PrivStr := 'Privil';
$80 : PrivStr := 'Favored';
$90 : PrivStr := 'Extra';
$A0 : PrivStr := 'Clerk';
$B0 : PrivStr := 'AsstSysop';
$D0 : PrivStr := 'Sysop';
$E0 : PrivStr := 'Hidden'
end {case}
end; {PrivStr}
procedure SetFile (var FP : longint; AN : word; PF, PT : byte);
var B1, B2 : byte;
FN : string[13];
begin {SetFile}
Read(FDat,B1); Read(FDat,B2);
if ((B1+(B2*256)) = AN) then
begin
Seek(FDat,(FP+15));
Read(FDat,B1);
if (B1 = PF) then
begin
Seek(FDat,(FP+2));
FN := '';
for B1 := 1 to 13 do
begin
Read(FDat,B2);
if (B2 = 0) then B2 := 32;
FN := FN + Chr(B2)
end;
Seek(FDat,(FP+15));
Write(FDat,PT);
Writeln(AN,' "',FN,'" ',PrivStr(PF),' -=> ',PrivStr(PT))
end
end;
Seek(FDat,(FP+36)); Read(FDat,B1); Read(FDat,B2); FP := FP + (B1+(B2*256));
Read(FDat,B1); FP := FP + B1;
Read(FDat,B1); FP := FP + B1;
FP := FP + ItemLen;
Seek(FDat,FP)
end; {SetFile}
begin {MAIN}
Configure;
GetName(FNam);
CheckCommandLine(ANum,FPF,FPT);
Writeln;
Assign(FDat,FNam);
{$I-} Reset(FDat); {$I+}
if (IOResult <> 0) then
begin
Writeln;
Writeln('Can''t open FilesBbsDat File ',FNam,'.');
Writeln('Please correct the problem or re-install the program from an original copy.');
Halt
end
else
begin
Writeln('Setting download privilege of files in area ',ANum,' from ',PrivStr(FPF),' to ',PrivStr(FPT),'.');
FPos := 0;
while (not Eof(FDat)) do
SetFile(FPos,ANum,FPF,FPT);
Close(FDat)
end
end. {MAIN}